<template>
  <div class="createuser">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model="form.userName"></el-input>
      </el-form-item>
      <el-form-item label="电话号码">
        <el-input v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.passWord"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit()">立即创建</el-button>
        <el-button @click="flesh()">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { adduserFunc } from "../http/request";
export default {
  name: "createuser",
  data() {
    return {
      form: {
        userName: "",
        phone: "",
        passWord: "",
      },
    };
  },
  methods: {
    onSubmit() {
      console.log("submit!");
      adduserFunc("/user/adduser", this.form);

      // 刷新页面
      this.$router.go(0);
    },
    flesh() {
      // 刷新页面
      this.$router.go(0);
    },
  },
};
</script>